<template>
  <el-dialog
    title="删除广告"
    :visible.sync="isShowDeleteDialog"
    width="681px"
    class="dialogTitle_G"
    @close="close"
  >
    <div class="deleteTip1_G" v-html="msg1 + this.currentSelect + msg2"></div>
    <div class="deleteTip2_G">确定<b>删除</b>选中的广告？</div>
    <div class="dialog-footer_G">
      <cs-btn
        type="primary"
        @click.native="confirmBtnClick"
        btnText="确定"
        :buttonStatus="buttonStatus"
      />
      <cs-btn @click.native="isShowDeleteDialog = false" btnText="取消"/>
    </div>
  </el-dialog>
</template>

<script>
import { mapGetters, mapState } from 'vuex'
import CsBtn from '@/components/CsBtn/CsBtn.vue'
import { delAdvertById } from '@/api/ad'

export default {
  name: 'adDelete',
  data() {
    return {
      isShowDeleteDialog: false,
      currentSelect: 1,
      msg1: '您已选择<b>',
      msg2: '个</b>广告',
      deleteId: [],
      buttonStatus: false
    }
  },
  components: {
    CsBtn
  },
  watch: {
    getShowAdDialogStatus(newValue) {
      if (newValue) {
        this.isShowDeleteDialog = newValue
      }
    }
  },
  computed: {
    ...mapState('ad', ['delId']),
    ...mapGetters('ad', ['getShowAdDialogStatus'])
  },
  methods: {
    close() {
      this.$store.commit('ad/changeShowAdDialogStatus', { state: false, id: [] })
    },
    async confirmBtnClick() {
      // console.log('确认删除', this.delId)
      const res = await delAdvertById(this.delId)
      this.$store.commit('ad/changeShowAdDialogStatus', { state: false, id: [] })
      // console.log('删除结构', res)
    }
  }
}
</script>

<style scoped></style>
